module.exports = class extends think.Logic {
	__before() {
		this.allowMethods = 'get,post';
	}

	addAction() {

		if(this.isPost) {
			let rules = {
				name: {
					string: true,
					required: true,
					aliasName: '权限名称'
				},
				code: {
					string: true,
					required: true,
					aliasName: '权限标识'
				}
				

			}
			let flag = this.validate(rules);

			if(!flag) {
				let errmsgs = [];
				for(let k in this.validateErrors) {
					errmsgs.push(this.validateErrors[k]);
				}
				return this.fail(errmsgs.join("<br/>"));
			}

		}

	}
	editAction() {

		if(this.isPost) {
			let rules = {
				name: {
					string: true,
					required: true,
					aliasName: '权限名称'
				},
				code: {
					string: true,
					required: true,
					aliasName: '权限标识'
				}

			}
			let flag = this.validate(rules);

			if(!flag) {
				let errmsgs = [];
				for(let k in this.validateErrors) {
					errmsgs.push(this.validateErrors[k]);
				}
				return this.fail(errmsgs.join("<br/>"));
			}

		}

	}

};